package proxy.d.extend;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author 黄军艳
 * @version 1.0
 * @date 2024/11/27  20:09
 */
public class IntermediaryInvocationHandler implements InvocationHandler {
    //声明目标对象
    private Object target;
    public IntermediaryInvocationHandler(Object target) {
        this.target = target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        // 添加代理业务
        System.out.println("前期准备");
        System.out.println("查找房源");
        System.out.println("和买家沟通时间");
        //执行目标对象的方法
        Object feedback = method.invoke(target, args);
        // 添加代理业务
        System.out.println("后期跟踪");
        System.out.println("和买家沟通意见");
        return feedback;
    }
}
